package com.fub.positioning;

import java.util.Arrays;
import java.util.List;

import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;

public class WifiProvider implements IWifiProvider {
	private Context context;
	String[] filter = { "test1", "EasyBox-890F07", "Sitecom" };
	List<String> APFilterList = Arrays.asList(this.filter);

	public WifiProvider(Context context) {
		this.context = context;
	}

	/**
	 * Returns a measurement with the signal strength to all access points.
	 */
	public Measurement measureAccessPointsSignalStrength() {
		Measurement measurement = new Measurement();
		WifiManager manager = (WifiManager) this.context
				.getSystemService(Context.WIFI_SERVICE);
		manager.startScan();
		List<ScanResult> scanResults = manager.getScanResults();
		if (scanResults != null)
			for (ScanResult result : scanResults) {
				if (this.APFilterList.contains(result.SSID)) {
					measurement.putSignalStrength(result.SSID, result.level);
				}
			}
		return measurement;
	}
}
